package com.jzy.stock.wareHourseGuishu.controller;

import com.jzy.stock.stockRoom.model.StockRoomSelectVo;
import com.jzy.stock.stockRoom.service.StockService;
import com.jzy.stock.util.ResultBuildVo;
import com.jzy.stock.util.ResultVo;
import com.jzy.stock.wareHourseGuishu.model.GuishuUpdateVo;
import com.jzy.stock.wareHourseGuishu.service.GuishuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author 贾志宇
 * @create 2022-07-13-14:14
 */
@RestController
@CrossOrigin
@Api(value = "HouseGuishuController", description = "库房归属功能")
public class HouseGuishuController {
    @Autowired
    private GuishuService guishuService;
    @Autowired
    private StockService stockService;


    @ApiOperation("库房查询接口")
    @PostMapping("warehouseGuishu/queryPage")
    public ResultVo queryPage1(@RequestBody @Valid StockRoomSelectVo stockRoomSelectVo, BindingResult bindingResult){
        if (bindingResult.hasErrors()){
            return ResultBuildVo.error(bindingResult.getFieldError().getDefaultMessage());
        }
        return stockService.queryPage1(stockRoomSelectVo);
    }
    @ApiOperation("根据库房查询库区接口")
    @PostMapping("warehouseGuishu/queryWareAreaByHouse")
    public ResultVo queryWareAreaByHouse(@RequestBody List<String> stockRoomCodeLists, BindingResult bindingResult){
        System.out.println(stockRoomCodeLists);
        if (bindingResult.hasErrors()){
            return ResultBuildVo.error(bindingResult.getFieldError().getDefaultMessage());
        }
        return guishuService.queryWareAreaByHouseCode(stockRoomCodeLists);
    }
    @ApiOperation("根据库区查询库位接口")
    @PostMapping("warehouseGuishu/queryWareWeiByArea")
    public ResultVo queryWareWeiByArea(@RequestBody List<String> wareAreaCodeLists){

        return guishuService.queryWareWeiByAreaCode(wareAreaCodeLists);
    }
    /**  弃用接口

    @ApiOperation("根据法人查询库位接口-弃用")
    @PostMapping("warehouseGuishu/queryWareWeiByLegalPersonCode")
    public ResultVo queryWareWeiByLegalPersonCode(String legalPersonCode){
        return guishuService.queryWareWeiByLegalPersonCode(legalPersonCode);
    }
    @ApiOperation("根据库位查询库区接口-弃用")
    @PostMapping("warehouseGuishu/queryWareAreaByWeiCode")
    public ResultVo queryWareAreaByWeiCode(@RequestBody List<String> WeiCodeLists, BindingResult bindingResult){
        if (bindingResult.hasErrors()){
            return ResultBuildVo.error(bindingResult.getFieldError().getDefaultMessage());
        }
        return guishuService.queryWareAreaByWeiCode(WeiCodeLists);
    }
    @ApiOperation("根据库区查询库房接口-弃用")
    @PostMapping("warehouseGuishu/queryWareHouseByAreaCode")
    public ResultVo queryWareHouseByAreaCode(@RequestBody List<String> AreaCodeLists, BindingResult bindingResult){
        if (bindingResult.hasErrors()){
            return ResultBuildVo.error(bindingResult.getFieldError().getDefaultMessage());
        }
        return guishuService.queryWareHouseByAreaCode(AreaCodeLists);
    }*/

    @ApiOperation("库房归属修改接口")
    @PostMapping("warehouseGuishu/updateWareHouseGuishu")
    public ResultVo updateWareHouseGuishu(@RequestBody GuishuUpdateVo guishuUpdateVo){
        System.out.println(guishuUpdateVo);
        return guishuService.updateWareHouseGuishu(guishuUpdateVo);
    }

    @ApiOperation("根据法人查询位区房接口")
    @PostMapping("warehouseGuishu/queryThreeListByLegalPersonCode")
    public ResultVo queryThreeListByLegalPersonCode(String legalPersonCode){
        return guishuService.queryThreeListByLegalPersonCode(legalPersonCode);
    }
}
